//
//  SurveyerStore.h
//  Surveyer
//
//  Created by Qikun Guo on 13-8-4.
//  Copyright (c) 2013年 Tim. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "Result.h"
#import "Survey.h"
#import "SurveyItem.h"
#import "App.h"
#import <MessageUI/MessageUI.h>
#import <ShareSDK/ShareSDK.h>

extern NSString * const SurveyerStoreUpdateNotification;

@interface SurveyerStore : NSObject<MFMailComposeViewControllerDelegate>
{
    NSManagedObjectContext *context;
    NSManagedObjectModel *model;
}
@property (nonatomic, strong) NSUndoManager *undoManager;
@property (nonatomic, strong) NSMutableArray *allSurvey;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) Survey *latestSurvey;
@property (nonatomic, strong) App *app;
@property (nonatomic, weak) UIViewController *delegateVC;

+ (SurveyerStore *)defaultStore;
- (NSString *)itemArchivePath;
- (void)contentChange:(NSNotification *)note;
- (BOOL)saveChanges;

- (void)load;
- (void)sort;
- (Survey *)createSurveyWithTitle:(NSString *)title;
- (SurveyItem *)createSurveyItemInSurvey:(Survey *)survey;
- (Result *)createResultWithSurveyItem:(SurveyItem *)item;
- (void)removeSurvey:(Survey *)survey;
- (void)removeUncompletedSurvey;

- (void)shareSurvey:(Survey *)survey ByType:(ShareType)type;
- (void)mailSurvey:(Survey *)survey WithDelegate:(UIViewController *)delegate;

- (NSString *)stringToShow;
- (Survey *)templateSurvey;
@end
